package com.itheimai02;

import java.util.TreeSet;

public class Work4Comparator {
    public static void main(String[] args) {
        TreeSet<Student> stu = new TreeSet<>((o1,o2)->{
            int num  = o2.getSum()-o1.getSum();
            num=num==0?o1.getAge()-o2.getAge():num;
            num=num==0?o1.getName().compareTo(o2.getName()):num;
            return num;
        });
       stu.add(new Student("Tom",20,90));
       stu.add(new Student("Jerry",22,95));
       stu.add(new Student("John",20,100));
       stu.add(new Student("Lily",22,100));
       stu.add(new Student("Lucy",22,90));
       stu.add(new Student("Kevin",22,90));

        for (Student student : stu) {
            System.out.println(student);

        }

    }
}
